home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / leprechn.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  11KB  |  351 lines

  1. /***************************************************************************
  2.  
  3.  Leprechaun memory map (preliminary)
  4.  
  5.  driver by Zsolt Vasvari
  6.  
  7.  Hold down F2 while pressing F3 to enter test mode. Hit Advance (F1) to
  8.  cycle through test and hit F2 to execute.
  9.  
  10.  
  11.  Main CPU
  12.  
  13.  0000-03ff RAM
  14.  8000-ffff ROM
  15.  
  16.  2000-200f, 2800-280f and 3000-300f might be some kind of programmable I/O
  17.  controller. I'm not knowledgable enough about them to be able to tell for sure.
  18.  I based the observation of the locations being written/read. They seem to
  19.  follow a similar pattern across all 3 areas. Anyone with schematics?
  20.  
  21.  I/O Read
  22.  
  23.  2000 Video RAM Read Back
  24.  200d ???
  25.  3002-3003 ???
  26.  2801 Input Port Read
  27.  
  28.  I/O Write
  29.  
  30.  2000 Graphics Command Write
  31.  2001 Graphics Data Write
  32.  2002-2003 ???
  33.  200c-200e ???
  34.  2800 Input Port Select
  35.  2802-2803 ???
  36.  280c ???
  37.  3001 Sound Command Write
  38.  3002-3003 ???
  39.  300c ???
  40.  
  41.  
  42.  Sound CPU
  43.  
  44.  0000-01ff RAM
  45.  f000-ffff ROM
  46.  
  47.  I/O Read
  48.  
  49.  0800 Sound Command Read
  50.  0804-0805 ???
  51.  080c ???
  52.  a001 ???
  53.  
  54.  I/O Write
  55.  
  56.  0801-0803 ???
  57.  0806 ???
  58.  081e ???
  59.  a000 AY8910 Control Port
  60.  a002 AY8910 Write Port
  61.  
  62.  ***************************************************************************/
  63.  
  64. #include "driver.h"
  65. #include "cpu/m6502/m6502.h"
  66.  
  67.  
  68. int  leprechn_vh_start(void);
  69. void leprechn_vh_stop(void);
  70. void leprechn_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  71.  
  72. WRITE_HANDLER( leprechn_graphics_command_w );
  73. READ_HANDLER( leprechn_graphics_data_r );
  74. WRITE_HANDLER( leprechn_graphics_data_w );
  75.  
  76. WRITE_HANDLER( leprechn_input_port_select_w );
  77. READ_HANDLER( leprechn_input_port_r );
  78. READ_HANDLER( leprechn_200d_r );
  79. READ_HANDLER( leprechn_0805_r );
  80.  
  81.  
  82.  
  83. WRITE_HANDLER( leprechn_sh_w )
  84. {
  85.     soundlatch_w(offset,data);
  86.     cpu_cause_interrupt(1,M6502_INT_IRQ);
  87. }
  88.  
  89.  
  90.  
  91. static struct MemoryReadAddress readmem[] =
  92. {
  93.     { 0x0000, 0x03ff, MRA_RAM},
  94.     { 0x2000, 0x2000, leprechn_graphics_data_r},
  95.     { 0x200d, 0x200d, leprechn_200d_r },
  96.     { 0x2801, 0x2801, leprechn_input_port_r },
  97.     { 0x3002, 0x3003, MRA_RAM},
  98.     { 0x8000, 0xffff, MRA_ROM},
  99.     { -1 }  /* end of table */
  100. };
  101.  
  102. static struct MemoryWriteAddress writemem[] =
  103. {
  104.     { 0x0000, 0x03ff, MWA_RAM},
  105.     { 0x2000, 0x2000, leprechn_graphics_command_w},
  106.     { 0x2001, 0x2001, leprechn_graphics_data_w},
  107.     { 0x2002, 0x2003, MWA_NOP },  // ???
  108.     { 0x200c, 0x200e, MWA_NOP },  // ???
  109.     { 0x2800, 0x2800, leprechn_input_port_select_w},
  110.     { 0x2802, 0x2803, MWA_NOP },  // ???
  111.     { 0x280c, 0x280c, MWA_NOP },  // ???
  112.     { 0x3001, 0x3001, leprechn_sh_w },
  113.     { 0x3002, 0x3003, MWA_RAM},   // ???
  114.     { 0x300c, 0x300c, MWA_NOP },  // ???
  115.     { 0x8000, 0xffff, MWA_ROM},
  116.     { -1 }  /* end of table */
  117. };
  118.  
  119. static struct MemoryReadAddress sound_readmem[] =
  120. {
  121.     { 0x0000, 0x01ff, MRA_RAM},
  122.     { 0x0800, 0x0800, soundlatch_r},
  123.     { 0x0804, 0x0804, MRA_RAM},   // ???
  124.     { 0x0805, 0x0805, leprechn_0805_r},   // ???
  125.     { 0x080c, 0x080c, MRA_RAM},   // ???
  126.     { 0xa001, 0xa001, MRA_RAM},   // ???
  127.     { 0xf000, 0xffff, MRA_ROM},
  128.     { -1 }  /* end of table */
  129. };
  130.  
  131.  
  132. static struct MemoryWriteAddress sound_writemem[] =
  133. {
  134.     { 0x0000, 0x01ff, MWA_RAM},
  135.     { 0x0801, 0x0803, MWA_RAM},   // ???
  136.     { 0x0806, 0x0806, MWA_RAM},   // ???
  137.     { 0x081e, 0x081e, MWA_RAM},   // ???
  138.     { 0xa000, 0xa000, AY8910_control_port_0_w },
  139.     { 0xa002, 0xa002, AY8910_write_port_0_w },
  140.     { 0xf000, 0xffff, MWA_ROM},
  141.     { -1 }  /* end of table */
  142. };
  143.  
  144. INPUT_PORTS_START( leprechn )
  145.     // All of these ports are read indirectly through 2800/2801
  146.     PORT_START      /* Input Port 0 */
  147.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_TILT ) // This is called "Slam" in the game
  148.     PORT_BITX(0x08, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
  149.     PORT_BITX(0x10, IP_ACTIVE_LOW, 0, "Advance", KEYCODE_F1, IP_JOY_NONE )
  150.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
  151.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
  152.     PORT_BIT( 0x23, IP_ACTIVE_LOW, IPT_UNUSED )
  153.  
  154.     PORT_START      /* Input Port 1 */
  155.     PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
  156.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_COCKTAIL )
  157.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_COCKTAIL )
  158.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
  159.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_COCKTAIL )
  160.  
  161.     PORT_START      /* Input Port 2 */
  162.     PORT_BIT( 0x5f, IP_ACTIVE_LOW, IPT_UNUSED )
  163.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
  164.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  165.  
  166.     PORT_START      /* Input Port 3 */
  167.     PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
  168.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  169.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  170.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  171.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY )
  172.  
  173.     PORT_START      /* DSW #1 */
  174.     PORT_DIPNAME( 0x09, 0x09, DEF_STR( Coin_B ) )
  175.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_1C ) )
  176.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_5C ) )
  177.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_6C ) )
  178.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_7C ) )
  179.     PORT_DIPNAME( 0x22, 0x22, "Max Credits" )
  180.     PORT_DIPSETTING(    0x22, "10" )
  181.     PORT_DIPSETTING(    0x20, "20" )
  182.     PORT_DIPSETTING(    0x02, "30" )
  183.     PORT_DIPSETTING(    0x00, "40" )
  184.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Cabinet ) )
  185.     PORT_DIPSETTING(    0x04, DEF_STR( Upright ) )
  186.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  187.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Free_Play ) )
  188.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  189.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  190.     PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_A ) )
  191.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_1C ) )
  192.     PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
  193.     PORT_DIPSETTING(    0x80, DEF_STR( 1C_3C ) )
  194.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_4C ) )
  195.  
  196.     PORT_START      /* DSW #2 */
  197.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )
  198.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  199.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  200.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Lives ) )
  201.     PORT_DIPSETTING(    0x08, "3" )
  202.     PORT_DIPSETTING(    0x00, "4" )
  203.     PORT_DIPNAME( 0xc0, 0x40, DEF_STR( Bonus_Life ) )
  204.     PORT_DIPSETTING(    0x40, "30000" )
  205.     PORT_DIPSETTING(    0x80, "60000" )
  206.     PORT_DIPSETTING(    0x00, "90000" )
  207.     PORT_DIPSETTING(    0xc0, "None" )
  208.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  209.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  210.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  211.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
  212.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  213.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  214.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  215.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  216.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  217.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  218.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  219.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  220. INPUT_PORTS_END
  221.  
  222.  
  223.  
  224. /* RGBI palette. Is it correct? */
  225. static unsigned char palette[16 * 3] =
  226. {
  227.     0x00, 0x00, 0x00,
  228.     0xff, 0x00, 0x00,
  229.     0x00, 0xff, 0x00,
  230.     0xff, 0xff, 0x00,
  231.     0x00, 0x00, 0xff,
  232.     0xff, 0x00, 0xff,
  233.     0x00, 0xff, 0xff,
  234.     0xff, 0xff, 0xff,
  235.     0x40, 0x40, 0x40,
  236.     0xff, 0x40, 0x40,
  237.     0x40, 0xff, 0x40,
  238.     0xff, 0xff, 0x40,
  239.     0x40, 0x40, 0xff,
  240.     0xff, 0x40, 0xff,
  241.     0x40, 0xff, 0xff,
  242.     0xff, 0xff, 0xff
  243. };
  244. static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
  245. {
  246.     memcpy(game_palette,palette,sizeof(palette));
  247. }
  248.  
  249.  
  250.  
  251. static struct AY8910interface ay8910_interface =
  252. {
  253.     1,      /* 1 chip */
  254.     14318000/8,     /* ? */
  255.     { 50 },
  256.     { 0 },
  257.     { 0 },
  258.     { 0 },
  259.     { 0 }
  260. };
  261.  
  262.  
  263. static struct MachineDriver machine_driver_leprechn =
  264. {
  265.     /* basic machine hardware */
  266.     {
  267.         // A good test to verify that the relative CPU speeds of the main
  268.         // and sound are correct, is when you finish a level, the sound
  269.         // should stop before the display switches to the name of the
  270.         // next level
  271.         {
  272.             CPU_M6502,
  273.             1250000,    /* 1.25 Mhz ??? */
  274.             readmem,writemem,0,0,
  275.             interrupt,1
  276.         },
  277.         {
  278.             CPU_M6502 | CPU_AUDIO_CPU,
  279.             1500000,    /* 1.5 Mhz ??? */
  280.             sound_readmem,sound_writemem,0,0,
  281.             ignore_interrupt,1      /* interrupts are triggered by the main CPU */
  282.         }
  283.     },
  284.     57, DEFAULT_60HZ_VBLANK_DURATION,       /* frames per second, vblank duration */
  285.     1,      /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  286.     0,
  287.  
  288.     /* video hardware */
  289.     256, 256, { 0, 256-1, 0, 256-1 },
  290.     0,
  291.     sizeof(palette) / sizeof(palette[0]) / 3, 0,
  292.     init_palette,
  293.  
  294.     VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY,
  295.     0,
  296.     leprechn_vh_start,
  297.     leprechn_vh_stop,
  298.     leprechn_vh_screenrefresh,
  299.  
  300.     /* sound hardware */
  301.     0,0,0,0,
  302.     {
  303.         {
  304.             SOUND_AY8910,
  305.             &ay8910_interface
  306.         }
  307.     }
  308. };
  309.  
  310.  
  311. /***************************************************************************
  312.  
  313.   Game driver(s)
  314.  
  315. ***************************************************************************/
  316.  
  317. ROM_START( leprechn )
  318.     ROM_REGION( 0x10000, REGION_CPU1 )  /* 64k for the main CPU */
  319.     ROM_LOAD( "lep1",         0x8000, 0x1000, 0x2c4a46ca )
  320.     ROM_LOAD( "lep2",         0x9000, 0x1000, 0x6ed26b3e )
  321.     ROM_LOAD( "lep3",         0xa000, 0x1000, 0xa2eaa016 )
  322.     ROM_LOAD( "lep4",         0xb000, 0x1000, 0x6c12a065 )
  323.     ROM_LOAD( "lep5",         0xc000, 0x1000, 0x21ddb539 )
  324.     ROM_LOAD( "lep6",         0xd000, 0x1000, 0x03c34dce )
  325.     ROM_LOAD( "lep7",         0xe000, 0x1000, 0x7e06d56d )
  326.     ROM_LOAD( "lep8",         0xf000, 0x1000, 0x097ede60 )
  327.  
  328.     ROM_REGION( 0x10000, REGION_CPU2 )  /* 64k for the audio CPU */
  329.     ROM_LOAD( "lepsound",     0xf000, 0x1000, 0x6651e294 )
  330. ROM_END
  331.  
  332. ROM_START( potogold )
  333.     ROM_REGION( 0x10000, REGION_CPU1 )  /* 64k for the main CPU */
  334.     ROM_LOAD( "pog.pg1",      0x8000, 0x1000, 0x9f1dbda6 )
  335.     ROM_LOAD( "pog.pg2",      0x9000, 0x1000, 0xa70e3811 )
  336.     ROM_LOAD( "pog.pg3",      0xa000, 0x1000, 0x81cfb516 )
  337.     ROM_LOAD( "pog.pg4",      0xb000, 0x1000, 0xd61b1f33 )
  338.     ROM_LOAD( "pog.pg5",      0xc000, 0x1000, 0xeee7597e )
  339.     ROM_LOAD( "pog.pg6",      0xd000, 0x1000, 0x25e682bc )
  340.     ROM_LOAD( "pog.pg7",      0xe000, 0x1000, 0x84399f54 )
  341.     ROM_LOAD( "pog.pg8",      0xf000, 0x1000, 0x9e995a1a )
  342.  
  343.     ROM_REGION( 0x10000, REGION_CPU2 )  /* 64k for the audio CPU */
  344.     ROM_LOAD( "pog.snd",      0xf000, 0x1000, 0xec61f0a4 )
  345. ROM_END
  346.  
  347.  
  348.  
  349. GAME( 1982, leprechn, 0,        leprechn, leprechn, 0, ROT0, "Tong Electronic", "Leprechaun" )
  350. GAME( 1982, potogold, leprechn, leprechn, leprechn, 0, ROT0, "GamePlan", "Pot of Gold" )
  351.